import java.util.Scanner;

/**
 * <p>接受一个十六进制的数，输出该数值的十进制表示</p>
 *
 *
 * @author: YuanChilde
 * @date: 2020-02-17 8:01
 * @version: 1.0
 * Modification History:
 * Date    Author      Version     Description
 * -----------------------------------------------------------------
 * 2020-02-17 8:01    YuanChilde     1.0        新增
 */
public class Demo7 {

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(sc.hasNextLine()){
            String s = sc.nextLine();
            String hex = s.substring(2);
            System.out.println(Integer.parseInt(hex,16));
        }
    }

}
